import React from 'react';

class Prent extends React.Component {
  // 1. 声明数据
  state = {
    name: '你好'
  }
  render() {
    return (
      <div>
        <p>父组件</p>
        {/* 2. 传值给子组件 */}
        <Son name={ this.state.name }/>
      </div>
    )
  }
}

class Son extends React.Component {
  render() {
    return (
      <div>
        <p>子组件</p>
        <hr />
        {/* 3. 子组件接收传递的值 */}
        <p>我是父组件传递过来的值: {this.props.name}</p>
      </div>
    )
  }
}

export default Prent